package com.wanshi.mapper;

import com.wanshi.pojo.Stu;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface StuMapper {

    @Select("SELECT * FROM `stu`,school,dorm,class where stu.school_id=school.school_id and stu.class_id=class.class_id and stu.dorm_id=dorm.dorm_id")
    List<Stu> getStuList();

    @Select("SELECT * FROM stu where stu_id= #{stu_id}")
    Stu getStuById(Integer stu_id);

    @Insert("INSERT INTO stu VALUES(0,#{stu_name},#{stu_gender},#{dorm_id},#{class_id},#{school_id})")
    String addStu(Stu stu);

    @Delete("DELETE FROM stu WHERE stu_id=#{stu_id}")
    void delStuById(Integer stu_id);

    @Update("UPDATE stu set stu_name=#{stu_name},stu_gender=#{stu_gender},dorm_id=#{dorm_id},class_id=#{class_id},school_id=#{school_id} where stu_id=#{stu_id}")
    void updateStuById(Integer stu_id);






}
